*{ Use the forum as admin }*

#{fixture delete:'all', load:'test-data.yml' /}

#{selenium 'Use the forum as Administrator'}
	clearSession()
	
	// Home page
	open('/')
	assertTextPresent('Still not a member ?')
	assertTextPresent('Forums')
	assertTextPresent('SysUsers help')
	assertTextPresent('About this sample application')
	assertTextPresent('7 posts in 4 topics')
	
	// Login
	clickAndWait('link=Login')
	assertTextPresent('Login')
	assertTextPresent('Email')
	assertTextPresent('Password')
	type('email', 'admin@sampleforum.com')
	type('password', 'hello')
	clickAndWait('loginButton')
	assertTextPresent('Welcome back Admin !')
	assertTextPresent('4 posts in 3 topics')
	assertTextNotPresent('Still not a member ?')
	
	// Create a new forum
	clickAndWait('link=Forums')
	assertTextPresent('Administrator options')
	assertTextPresent('Create a new forum')
	type('name', 'Héhé')
	type('description', 'A new forum')
	clickAndWait('addForum')
	
	// Check
	assertTextPresent('Héhé')
	assertTextPresent('A new forum')
	assertTextPresent('0 posts in 0 topics')
	
	// Delete a forum
	clickAndWait('link=Play help')
	assertTextPresent('Delete this forum')
	clickAndWait('deleteIt')
	assertTextPresent('The forum has been deleted')
	assertTextPresent('About')
	assertTextPresent('Héhé')
	assertTextNotPresent('Play help')

	// Delete a topic
	clickAndWait('link=About')
	clickAndWait('link=About play')
	assertTextPresent('Delete this topic')
	clickAndWait('deleteIt')
	
	// Check admin has no more posts
	clickAndWait('link=Admin')
	assertTextPresent('Admin')
	assertTextPresent('0 posts in 0 topics')
	assertTextPresent('No post by this user')
	
	// Logout
	clickAndWait('link=Logout')
	assertTextPresent('been logged out')
	assertTextPresent('0 posts in 0 topics')
	
#{/selenium}